package com.jzo2o.market.controller.operation;

import com.jzo2o.common.model.PageResult;
import com.jzo2o.market.model.dto.request.ActivityQueryForPageReqDTO;
import com.jzo2o.market.model.dto.request.ActivitySaveReqDTO;
import com.jzo2o.market.model.dto.response.ActivityInfoResDTO;
import com.jzo2o.market.service.IActivityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 优惠券活动 控制层
 *
 * @Author mr.fu
 * @Date 2025/2/8 10:31
 */
@RestController
@RequestMapping("/operation/activity")
@Api(tags = "优惠券活动处理类")
public class ActivityController {

    @Autowired
    private IActivityService activityService;

    @PostMapping("/save")
    @ApiOperation("新增优惠券活动")
    public void saveCouponActivity(@RequestBody ActivitySaveReqDTO dto) {
        activityService.saveCouponActivity(dto);
    }

    @GetMapping("/page")
    @ApiOperation("查询优惠券列表")
    public PageResult<ActivityInfoResDTO> pageList(ActivityQueryForPageReqDTO dto) {
        return activityService.pageList(dto);
    }

    @GetMapping("/{id}")
    @ApiOperation("查询优惠券详情")
    public ActivityInfoResDTO getActivityById(@PathVariable Long id) {
        return activityService.getActivityById(id);
    }

    @PostMapping("/revoke/{id}")
    @ApiOperation("撤销优惠券活动")
    public void revoke(@PathVariable Long id){
         activityService.revoke(id);
    }
}
